home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 1 / Gold Medal Software Volume 1 (Gold Medal) (1994).iso / prog / tpwprog7.arj / TRANSFER.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-07-02  |  3.1 KB  |  121 lines

  1. { transfer.pas -- Demonstrate OWL's transfer mechanism }
  2.  
  3. program Transfer;
  4.  
  5. {$R transfer.res}
  6.  
  7. uses WinTypes, WinProcs, WObjects;
  8.  
  9. const
  10.  
  11.   id_Menu    = 100;   { Menu resource ID }
  12.   id_Dialog  = 200;   { Dialog resource ID }
  13.   cm_Dialog  = 101;   { Dialog command value }
  14.   cm_Quit    = 102;   { Exit command value }
  15.   id_CBGroup = 101;   { Check box group ID }
  16.   id_RBGroup = 102;   { Radio button group ID }
  17.   id_CB1     = 103;   { Check box IDs }
  18.   id_CB2     = 104;
  19.   id_CB3     = 105;
  20.   id_RB1     = 106;   { Radio button IDs }
  21.   id_RB2     = 107;
  22.   id_Edit    = 108;   { Edit control ID }
  23.   editLen    = 128;   { Maximum length of edit control }
  24.  
  25. type
  26.  
  27.   TransferRec = record
  28.     CB1, CB2, CB3: Word;
  29.     RB1, RB2: Word;
  30.     Edit: array[0 .. editLen] of Char
  31.   end;
  32.  
  33.   TransferApplication = object(TApplication)
  34.     procedure InitMainWindow; virtual;
  35.   end;
  36.  
  37.   PTransferWindow = ^TransferWindow;
  38.   TransferWindow = object(TWindow)
  39.     DiagData: TransferRec;
  40.     constructor Init(AParent: PWindowsObject; ATitle: PChar);
  41.     procedure CMDialog(var Msg: TMessage);
  42.       virtual cm_First + cm_Dialog;
  43.     procedure CMQuit(var Msg: TMessage);
  44.       virtual cm_First + cm_Quit;
  45.   end;
  46.  
  47.   PTransferDlg = ^TransferDlg;
  48.   TransferDlg = object(TDialog)
  49.     constructor Init(AParent: PWindowsObject; AName: PChar);
  50.   end;
  51.  
  52.  
  53. { TransferApplication }
  54.  
  55. {- Initialize TransferApplication object's window }
  56. procedure TransferApplication.InitMainWindow;
  57. begin
  58.   MainWindow := New(PTransferWindow, Init(nil, 'Transfer Demo'))
  59. end;
  60.  
  61.  
  62. { TransferWindow }
  63.  
  64. {- Construct TransferWindow object }
  65. constructor TransferWindow.Init(AParent: PWindowsObject; ATitle: PChar);
  66. begin
  67.   TWindow.Init(AParent, ATitle);
  68.   Attr.Menu := LoadMenu(HInstance, PChar(id_Menu));
  69.   FillChar(DiagData, Sizeof(DiagData), 0);
  70.   DiagData.RB1 := 1
  71. end;
  72.  
  73. {- Execute Dialog command }
  74. procedure TransferWindow.CMDialog(var Msg: TMessage);
  75. var
  76.   PD: PDialog;
  77. begin
  78.   PD := New(PTransferDlg, Init(@Self, PChar(id_Dialog)));
  79.   PD^.TransferBuffer := @DiagData;
  80.   Application^.ExecDialog(PD)
  81. end;
  82.  
  83. {- Execute Exit command }
  84. procedure TransferWindow.CMQuit(var Msg: TMessage);
  85. begin
  86.   CloseWindow
  87. end;
  88.  
  89.  
  90. { TransferDlg }
  91.  
  92. {- Construct TransferDlg instance }
  93. constructor TransferDlg.Init(AParent: PWindowsObject; AName: PChar);
  94. var
  95.   AControl: PControl;
  96. begin
  97.   TDialog.Init(AParent, AName);
  98.   AControl := New(PCheckBox, InitResource(@Self, id_CB1));
  99.   AControl := New(PCheckBox, InitResource(@Self, id_CB2));
  100.   AControl := New(PCheckBox, InitResource(@Self, id_CB2));
  101.   AControl := New(PRadioButton, InitResource(@Self, id_RB1));
  102.   AControl := New(PRadioButton, InitResource(@Self, id_RB2));
  103.   AControl := New(PEdit, InitResource(@Self, id_Edit, editlen + 1));
  104. end;
  105.  
  106. var
  107.  
  108.   TransferApp: TransferApplication;
  109.  
  110. begin
  111.   TransferApp.Init('TransferApp');
  112.   TransferApp.Run;
  113.   TransferApp.Done
  114. end.
  115.  
  116.  
  117. {--------------------------------------------------------------
  118.   Copyright (c) 1991 by Tom Swan. All rights reserved.
  119.   Revision 1.00    Date: 5/11/1991
  120. ---------------------------------------------------------------}
  121.